from time import sleep
import page
from base.base import Base


class PageAppOrder(Base):
    def page_app_click_index(self):
        sleep(1)
        self.base_click(page.app_order_index)

    def page_app_click_search_text(self):
        self.base_click(page.app_order_search_text1)

    def page_app_input_searh_text(self, search_name='小米'):
        self.base_input(page.app_order_search_text2, search_name)

    def page_app_click_search_btn(self):
        self.base_click(page.app_order_search_btn)

    def page_app_select_goods(self):
        self.base_click(page.app_order_click_img)

    def page_app_add_cart(self):
        self.base_click(page.app_order_add_cart)

    def page_app_cart_ok(self):
        self.base_click(page.app_order_cart_ok)

    def page_app_click_cart(self):
        self.base_click(page.app_order_click_cart)

    def page_app_now_purchase(self):
        self.base_click(page.app_order_now_purchase)

    def page_app_click_submit_order(self):
        self.base_click(page.app_order_click_submit_order)

    def page_app_click_now_pay(self):
        self.base_click(page.app_order_click_now_pay)

    def page_app_input_pwd(self, pwd='123456'):
        self.base_input(page.app_order_pwd, pwd)

    def page_app_click_sure(self):
        self.base_click(page.app_order_pwd_sure)

    def page_app_get_order_number(self):
        return self.base_get_text(page.app_order_order_number)

    def page_app_order(self, search_name='小米', pwd='123456'):
        self.page_app_click_index()
        self.page_app_click_search_text()
        self.page_app_input_searh_text(search_name)
        self.page_app_click_search_btn()
        self.page_app_select_goods()
        self.page_app_add_cart()
        self.page_app_cart_ok()
        self.page_app_click_cart()
        self.page_app_now_purchase()
        self.page_app_click_submit_order()
        self.page_app_click_now_pay()
        self.page_app_input_pwd(pwd)
        self.page_app_click_sure()
        self.page_app_get_order_number()
